package com.example.beryl.http;
import com.example.beryl.Util.Android_log;
import com.example.beryl.entity.Action;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 开工记录网络方法
 */
public class Net_startWork {
    private ArrayList<String> arrayList = new ArrayList<String>();
    private ArrayList<String> brrayList = new ArrayList<String>();
    private ArrayList<String> crrayList = new ArrayList<String>();
    //private static String URL ="StartWork.asmx";//服务器地址
    private static String URL ="StartWork.asmx";//调试地址
    private Net_method soap2 = new Net_method();

    public List<String> SW_CommonMethod(String what, String para)
    {
        Android_log log = new Android_log();
        List<String> list = new ArrayList<>();
        try
        {
            switch (what)
            {
                case Action.action.GetBarcode:
                    list = getStartWork(para);
                    break;
                case Action.action.getProce:
                    list = getProcess(para);
                    break;
                case Action.action.getSelect:
                    list = getSelect(para);
                    break;
                case Action.action.getCQTag:
                    list = getCQTag(para);
                    break;
                case Action.action.getMOLotNo:
                    list = getMOLotNo(para);
                    break;
                case Action.action.summitBG:
                    list = summitBG(para);
                    break;
            }

        }catch (Exception e)
        {

        }
        return list;
    }

    //得到流传单信息
    public List<String> getStartWork(String data)
    {
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        arrayList.add("para");
        brrayList.add(data);
        try
        {
            crrayList = soap2.SummitData("getStartWork", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    //得到工序列表
    public List<String> getProcess(String data)
    {
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        arrayList.add("para");
        brrayList.add(data);
        try
        {
            crrayList = soap2.SummitData("getProcess", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    public List<String> getSelect(String data)
    {
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        arrayList.add("para");
        brrayList.add(data);
        try
        {
            crrayList = soap2.SummitData("getSelect", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    //裁切标签循环
    public List<String> getCQTag(String data)
    {
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        arrayList.add("para");
        brrayList.add(data);
        try
        {
            crrayList = soap2.SummitData("getCQTag", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    //获取批次号
    public List<String> getMOLotNo(String data)
    {
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        arrayList.add("para");
        brrayList.add(data);
        try
        {
            crrayList = soap2.SummitData("getMOLotNo", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    //报工记录提交
    public List<String> summitBG(String data)
    {
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        arrayList.add("para");
        brrayList.add(data);
        try
        {
            crrayList = soap2.SummitData("summitBG", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }
}
